requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0) | 您所在的位置:网站首页 › 12306 4001错误代码 › requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0) |
首先正解错误:请求异常,JSON解码错误:期待值:一行一列(没有字符)。 该问题常见于向某网站进行一些数据的爬取。 错误代码: url='https://kyfw.12306.cn/otn/leftTicket/queryZ?leftTicketDTO.train_date={}&leftTicketDTO.from_station={}&leftTicketDTO.to_station={}&purpose_codes=ADULT'.format(date,from_station,to_station) #发送查询请求 #url='https://kyfw.12306.cn/otn/leftTicket/queryZ?leftTicketDTO.train_date=2023-05-12&leftTicketDTO.from_station=BJP&leftTicketDTO.to_station=SHH&purpose_codes=ADULT' response=requests.get(url,headers=headers) print(response.text) #将Json数据转换为字典类型,通过键值对获取数据 result=response.json() #将数值类型转换为字典类型 # result=result['data']['result'] #先获取键"data"对应的值,然后在值中获取键“result”对应的值为什么出现这种错误,按照报错理解是response中没有json文件类型,(json数据类型类似于python中的字典),实际就是没有读到想要的数据。 错误现象:  é路客æ·æå¡ä¸å¿ |
CopyRight 2018-2019 实验室设备网 版权所有 |